/*
 * Copyright (c) 2009 Roman Savelyev
 *
 * Permission is hereby granted, free of charge, to any person obtaining a copy
 * of this software and associated documentation files (the "Software"), to deal
 * in the Software without restriction, including without limitation the rights
 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
 * copies of the Software, and to permit persons to whom the Software is
 * furnished to do so, subject to the following conditions:
 *
 * The above copyright notice and this permission notice shall be included in
 * all copies or substantial portions of the Software.
 *
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
 * THE SOFTWARE.
 */

#ifndef __CONUITERMINAL_H__
#define __CONUITERMINAL_H__

#include <e32base.h>
#include "conuidef.h"
#include "conuiterminaluid.hrh"
#include <e32twin.h>

const TUid KConTerminalInterfaceUid = {KConTerminalInterfaceUidValue};

class MConUiTerminalObserver
    {
public:
    virtual void HandleTerminalError(TInt aError) = 0;
    };

class CConUiTerminal : public CBase
    {
public:
    IMPORT_C static CConUiTerminal* NewL(const TDesC8& aTerminalType, MConUiTerminalObserver& aObserver);
    IMPORT_C ~CConUiTerminal();
public:
    IMPORT_C TSize SurfaceSize();
    IMPORT_C void SetBackground(ConUiDef::TColor aColor);
    IMPORT_C void SetForeground(ConUiDef::TColor aColor);
    IMPORT_C void SetBold(TBool aBold);
    IMPORT_C void SetInverseVideo(TBool aInverseVideo);
    IMPORT_C void SetPos(const TPoint& aPoint);
    IMPORT_C void HideCursor();
    IMPORT_C void ShowCursor();
    IMPORT_C void Write(const TDesC& aOutput);
    IMPORT_C void ClearSurface();
    IMPORT_C void ReadKey(TConsoleKey& aKey, TRequestStatus& aStatus);
    IMPORT_C void ReadKeyCancel();
protected:
    virtual TInt DoSurfaceSize(TSize& aSize) = 0;
    virtual TInt DoSetBackground(ConUiDef::TColor aColor) = 0;
    virtual TInt DoSetForeground(ConUiDef::TColor aColor) = 0;
    virtual TInt DoSetBold(TBool aBold) = 0;
    virtual TInt DoSetInverseVideo(TBool aInverseVideo) = 0;
    virtual TInt DoSetPos(const TPoint& aPoint) = 0;
    virtual TInt DoHideCursor() = 0;
    virtual TInt DoShowCursor() = 0;
    virtual TInt DoWrite(const TDesC& aOutput) = 0;
    virtual TInt DoClearSurface() = 0;
    virtual void DoReadKey(TConsoleKey& aKey, TRequestStatus& aStatus) = 0;
    virtual void DoReadKeyCancel() = 0;
private:
    MConUiTerminalObserver* iObserver;
    TUid iDtor_ID_Key;
    };

#endif /* __CONUITERMINAL_H__ */
